<?php

class View_Helper_MenuHelper extends Model3_View_Helper {

    private $_cr;

    public function display() {
        if (Model3_Auth::isAuth()) {
            $this->_cr = Model3_Auth::getCredentials();
            $dbs = Model3_Registry::getInstance()->get('databases');
            $em = $dbs['DefaultDb'];
            $user = $em->find('DefaultDb_Entities_Usuarios', $this->_cr['id']);
            switch ($this->_cr['type']) {
                case DefaultDb_Entities_Usuarios::USER_ADMIN :
                    $this->displayMenuAdmin();
                    break;
                default:
                    Model3_Auth::deleteCredentials();
                    $this->displayMenuNone();
                    break;
            }
        } else {
            $this->displayMenuClient();
        }
    }

    private function printLogOut($cr) {
        ?>
        <ul class="nav pull-right">
            <li><a>Usuario: <?php echo $cr['username']; ?></a></li>
            <li><a href="#" title="cerrar sesion" id="sessionExit"><i class="icon-off icon-white" ></i> Salir</a></li>
        </ul>
        <?php
    }

    private function displayMenuAdmin() {
        ?>
        <div class="navbar">
            <div class="">
                <div class="container">
                    <div class="nav-collapse">
                        <ul class="nav">
                            <li><a href="<?php echo $this->_view->url(array('module' => '', 'controller' => 'Dashboard', 'action' => 'index')); ?>" >Inicio</a> </li>
                            <li><a href="<?php echo $this->_view->url(array('module' => '', 'controller' => 'Reportes', 'action' => 'index')); ?>" >Reportes</a></li>
                        </ul>
                        <?php $this->printLogOut($this->_cr); ?>
                    </div>
                </div>
            </div>
        </div>
        <?php
    }

    private function displayMenuClient() {
        ?>
        <div class="navbar">
            <div class="">
                <div class="container">
                    <div class="nav-collapse">
                        <ul class="nav">
                            <li><a href="<?php echo $this->_view->url(array('module' => '', 'controller' => 'Index', 'action' => 'index')) ?>" ><i class="icon-home icon-white"></i>Inicio</a> </li>
                            <li><a href="<?php echo $this->_view->url(array('module' => '', 'controller' => 'Index', 'action' => 'gallery')) ?>" ><i class="icon-book"></i>Galerias</a></li>
                            <li><a href="<?php echo $this->_view->url(array('module' => '', 'controller' => 'Index', 'action' => 'direction')) ?>" ><i class="icon-book"></i>Direcci&oacute;n</a></li>
                            <li><a href="<?php echo $this->_view->url(array('module' => '', 'controller' => 'Index', 'action' => 'contactUs')) ?>" ><i class="icon-folder-close"></i>Contacto</a></li>
                            <li><a href="<?php echo $this->_view->url(array('module' => '', 'controller' => 'Reservaciones', 'action' => 'index')) ?>" ><i class="icon-folder-close"></i>Reservaciones</a></li>
                            <li><a href="<?php echo $this->_view->url(array('module' => '', 'controller' => 'Index', 'action' => 'login')) ?>" ><i class="icon-lock"></i>Login</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <?php
    }

    private function displayMenuNone() {
        ?>
        <div class="navbar ">
            <div class="navbar-inner">
                <div class="container">
                    <ul class="nav">
                        <li><a href="<?php echo $this->_view->url(array('module' => false, 'controller' => 'Index', 'action' => 'index')) ?>" ><?php echo ($this->_view->TrHelper()->_('Inicio')); ?></a> </li>
                    </ul>
                </div>
            </div>
        </div>
        <?php
    }

}
